from pywebio import *
from pywebio.input import *
from pywebio.output import *
from pywebio.session import *
from pywebio import *

def yaw_upload():
    filename = '../../data/yawData/hisSurfaceProcess.csv'
    content = open(filename, 'rb').read()
    put_button('下载文件', lambda: download('hisSurfaceProcess.csv', content))

    f = input.file_upload("上传文件")
    # Config = open('../../data/yawData/' + f['filename'], 'wb').write(f['content'])
    Config = open(filename, 'wb').write(f['content'])
    if (Config):
        put_text("上传yaw的hisSurfaceProcess文件成功")

def pitch_upload():
    filename = '../../data/pitchData/hisSurfaceProcess.csv'
    content = open(filename, 'rb').read()
    put_button('下载文件', lambda: download('hisSurfaceProcess.csv', content))

    f = input.file_upload("上传文件")
    Config = open(filename, 'wb').write(f['content'])
    if (Config):
        put_text("上传pitch的hisSurfaceProcess文件成功")

def torque_upload():

    filename = '../../data/torqueData/hisLambdaOptProcess.csv'
    content = open(filename, 'rb').read()
    put_button('下载文件', lambda: download('hisLambdaOptProcess.csv', content))

    f = input.file_upload("上传文件")
    Config = open(filename, 'wb').write(f['content'])
    if (Config):
        put_text("上传torque的hisLambdaOptProcess文件成功")

if __name__ == '__main__':
    start_server(yaw_upload, port=9999, debug=False)